package com.ruoyi.system.service.impl;

import java.util.Collections;
import java.util.List;

import com.ruoyi.system.domain.DDishCategories;
import com.ruoyi.system.domain.DFlavors;
import com.ruoyi.system.domain.DSizes;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.DDishesMapper;
import com.ruoyi.system.domain.DDishes;
import com.ruoyi.system.service.IDDishesService;

/**
 * 菜品档案Service业务层处理
 *
 * @author tjm
 * @date 2025-04-03
 */
@Service
public class DDishesServiceImpl implements IDDishesService
{
    @Autowired
    private DDishesMapper dDishesMapper;

    /**
     * 查询菜品档案
     *
     * @param id 菜品档案主键
     * @return 菜品档案
     */
    @Override
    public DDishes selectDDishesById(Long id)
    {
        return dDishesMapper.selectDDishesById(id);
    }

    /**
     * 查询菜品档案列表
     *
     * @param dDishes 菜品档案
     * @return 菜品档案
     */
    @Override
    public List<DDishes> selectDDishesList(DDishes dDishes)
    {
        List<DDishes> list = dDishesMapper.selectDDishesList(dDishes);
        for (DDishes dishes : list) {
            String kwName=dDishesMapper.findkwName(dishes.getFid());
            String lbName=dDishesMapper.findLbName(dishes.getCategoriesId());
            String ggName =dDishesMapper.findsizesById(dishes.getSizesId());
            dishes.setKwName(kwName);
            dishes.setLbName(lbName);
            dishes.setGgName(ggName);
        }
        System.out.println(list);

        return list;
    }

    /**
     * 新增菜品档案
     *
     * @param dDishes 菜品档案
     * @return 结果
     */
    @Override
    public int insertDDishes(DDishes dDishes)
    {
        return dDishesMapper.insertDDishes(dDishes);
    }

    /**
     * 修改菜品档案
     *
     * @param dDishes 菜品档案
     * @return 结果
     */
    @Override
    public int updateDDishes(DDishes dDishes)
    {
        return dDishesMapper.updateDDishes(dDishes);
    }

    /**
     * 批量删除菜品档案
     *
     * @param ids 需要删除的菜品档案主键
     * @return 结果
     */
    @Override
    public int deleteDDishesByIds(Long[] ids)
    {
        return dDishesMapper.deleteDDishesByIds(ids);
    }

    /**
     * 删除菜品档案信息
     *
     * @param id 菜品档案主键
     * @return 结果
     */
    @Override
    public int deleteDDishesById(Long id)
    {
        return dDishesMapper.deleteDDishesById(id);
    }

    @Override
    public List<DDishes> priceRank() {
        List<DDishes>dDishes=dDishesMapper.priceRank();
        return dDishes;

    }

    @Override
    public List<DFlavors> flavor() {
        List<DFlavors> dFlavors=dDishesMapper.flavor();
        return dFlavors;
    }

    @Override
    public List<DDishCategories> category() {
        List<DDishCategories> dDishCategories=dDishesMapper.category();
        return dDishCategories;
    }

    @Override
    public List<DSizes> specification() {
        List<DSizes> dSizes=dDishesMapper.specification();
        return dSizes;
    }


}
